/*
 * This file is part of ksPlatform
 * 
 * Copyright (c) 2014-2015
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at 97041437@qq.com.
 */

package cn.com.ksplatform.modules.system.auth.rolemanager.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;

import cn.com.ksplatform.base.BaseModel;
import cn.com.ksplatform.modules.system.auth.buttonmanager.model.PlatButton;
import cn.com.ksplatform.modules.system.auth.menumanager.model.PlatMenu;
import cn.com.ksplatform.modules.system.auth.resourcemanager.model.PlatResource;
import cn.com.ksplatform.modules.system.auth.usermanager.model.PlatUser;

/**
 * ClassName:PlatRole <br/>
 * Date: 2015年5月8日 下午4:55:58 <br/>
 * 
 * @author Mr.Luoxing
 * @version 1.0
 */
@Entity
@Table(name = "t_sys_role")
public class PlatRole extends BaseModel {
	@Id
	@GenericGenerator(name = "systemUUID", strategy = "uuid")
	@GeneratedValue(generator = "systemUUID")
	@Column(name = "roleId")
	private String roleId;// 唯一标示
	private String roleName;// 角色名称
	@Column(unique=true,nullable=false)
	private String roleCode;// 角色编码
	private String enabled;

	@ManyToMany(mappedBy = "roles")
	@JsonIgnore
	private Set<PlatUser> users = new HashSet<PlatUser>(0);

	@ManyToMany(mappedBy = "roles")
	@OrderBy("resourceid")
	@JsonIgnore
	private Set<PlatResource> resources = new HashSet<PlatResource>(0);

	@ManyToMany(mappedBy = "roles")
	@OrderBy("menuSort")
	@JsonIgnore
	private Set<PlatMenu> menus = new HashSet<PlatMenu>(0);

	@ManyToMany(mappedBy = "roles")
	@OrderBy("btnId")
	@JsonIgnore
	private Set<PlatButton> btns = new HashSet<PlatButton>(0);

	public String getRoleId() {
		return roleId;
	}

	public void setRoleId(String roleId) {
		this.roleId = roleId;
	}

	public String getRoleName() {
		return this.roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public String getRoleCode() {
		return this.roleCode;
	}

	public void setRoleCode(String roleCode) {
		this.roleCode = roleCode;
	}

	public Set<PlatUser> getUsers() {
		return users;
	}

	public Set<PlatResource> getResources() {
		return resources;
	}

	public void setResources(Set<PlatResource> resources) {
		this.resources = resources;
	}

	public Set<PlatMenu> getMenus() {
		return menus;
	}

	public void setMenus(Set<PlatMenu> menus) {
		this.menus = menus;
	}

	public Set<PlatButton> getBtns() {
		return btns;
	}

	public void setBtns(Set<PlatButton> btns) {
		this.btns = btns;
	}

	public void setUsers(Set<PlatUser> users) {
		this.users = users;
	}

	public String getEnabled() {
		return enabled;
	}

	public void setEnabled(String enabled) {
		this.enabled = enabled;
	}

}
